<%@ Page language="c#" Inherits="FlashBack.Web.SlideShow" CodeFile="SlideShow.aspx.cs" CodeFileBaseClass="FlashBack.Web.PageBase" %>
<HTML>
	<HEAD>
		<% Response.Expires = -1; %>
		<meta name="GENERATOR" Content="Microsoft Visual Studio 7.0">
		<meta name="CODE_LANGUAGE" Content="C#">
		<LINK REL="stylesheet" Type="text/css" HREF="FlashBack.css">
			<script src="cjs/ua.js"></script>
			<script src="cjs/xbDOM.js"></script>
			<script language="javascript">
function SetSlideTarget(i_path)
{
	var i = document.getElementById("slidespan");
	i.innerHTML = '<img class="SlideShow" id="slide" src="' + i_path + '" onload="ResizePicture()">';
}

var slideshow="<%=Slide_Show.CommandArgument%>";

function OnLoad()
{
  if(slideshow == "Yes")
  {
  	window.setTimeout(NextPicture,<%=m_Slide_Timeout%>);
  }
}

function NextPicture()
{
  if(slideshow != "Yes")
	return;

  var nb = document.getElementById("Next")
  if(nb)
  	nb.click();		
}

function ResizePicture()
{
	var i = document.getElementById("slide");
	var fs = document.getElementById("filmstrip");
	 
	var o_h = i.height;
	var o_w = i.width;
	var n_h = o_h;
	var n_w = o_w;
	 
	var ratio = o_h/o_w;
			
	var max_h = xbGetWindowHeight() - 45;
	var max_w = xbGetWindowWidth() - 30 - fs.width;
	 
	if(o_h > max_h)
	{
		n_h = max_h;
		n_w = n_h / ratio
	}
	 
	if(n_w > max_w)
	{
		n_w = max_w;
		n_h = n_w*ratio;
	}
	
	i.height = n_h;
	i.width = n_w;
	 
	try
	{
		i.filters[0].Apply();
		i.style.visibility = "visible";
		i.filters[0].Play();
	}
	catch(e)
	{
		i.style.visibility = "visible";
	}
 }
 
function ToggleFilmStrip()
{
	fsf = document.getElementById("filmstripframe");
	fst = document.getElementById("stripcontrol");
	
	if(fsf == null || fst == null)
		return;

	if(fsf.innerHTML == "")
	{
		if(slideshow == "Yes")
		{
			slideshow = "Pause"; //pause the slide show if it was on before
		}

		var hgt = "100%";			
		
		if(	navigator.family == "gecko" )
		{
			hgt = "600";
		}

		fsf.innerHTML = '<iframe frameborder="no" width="100%" height="' + hgt + '" src="FilmStrip.aspx?' + '<% =m_StripSource %>' + '"></iframe>'
		fst.src="images/right.gif";
	}
	else		
	{
		if(slideshow == "Pause") //resume the slide show if it was on before
		{
			slideshow = "Yes";
			NextPicture();
		}	
		
		fsf.innerHTML = "";
		fst.src="images/left.gif";
	}
	
	ResizePicture();
}
  
			</script>
	</HEAD>
	<body scroll="no" onload="OnLoad()">
		<form method="post" runat="server">
			<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
				<tr class="Header">
					<td height="26" nowrap>
						<asp:label style="MARGIN-LEFT:8px;WIDTH:40%" id="title" runat="server"></asp:label>
					</td>
					<td align="middle" nowrap>
						<asp:ImageButton ImageUrl="images/gobegin.gif" tooltip="Go To Start" commandname="move" commandargument="0" id="Begin" oncommand="GoBegin" runat="server"></asp:ImageButton>
						<asp:ImageButton ImageUrl="images/goback.gif" tooltip="Previous picture" commandname="move" commandargument="0" id="Previous" oncommand="GoPrevious" runat="server"></asp:ImageButton>
						<asp:ImageButton ImageUrl="images/gofw.gif" tooltip="Next picture" commandname="move" commandargument="0" id="Next" oncommand="GoNext" runat="server"></asp:ImageButton>
						<asp:ImageButton ImageUrl="images/goend.gif" tooltip="Go To End" commandname="move" commandargument="0" id="End" oncommand="GoEnd" runat="server"></asp:ImageButton>
						<asp:ImageButton ImageUrl="images/StopSlideShow.gif" tooltip="Click here to start a slide show" commandargument="Yes" commandname="StartSlideShow" id="Slide_Show" oncommand="ToggleSlideShow" runat="Server"></asp:ImageButton>
					</td>
					<td align="right" nowrap>
						<asp:checkbox id="UseOriginals" AutoPostBack="True" runat="server" tooltip="The original picture is the one that was originaly captured by the camera." text="Use originals" oncheckedchanged="UseOriginals_CheckedChanged"></asp:checkbox>
					</td>
					<td>
						<asp:hyperlink id="HomeLink" NavigateUrl="WhatIsNew.aspx" Visible="False" title="Go back to the album list" runat="Server">Home</asp:hyperlink>
					</td>
				</tr>
				<tr>
					<td height="100%" colspan="5" align="middle" width="100%" valign="center">
						<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
							<tr>
								<td height="100%" width="100%" align="middle" valign="center">
									<span id="slidespan">
										<img class="SlideShow" id="slide" title="<%= tooltipText %>" src="<% = slide %>" onload="ResizePicture()"></span>
									<div align="center"><asp:Label ID="Picturename" CssClass="Footnote" Runat="server">PicName</asp:Label></div>
								</td>
								<td height="100%">
									<asp:PlaceHolder ID="strippane" Runat="server">
										<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
											<tr>
												<td id="filmstrip" valign="top" align="left" title="Shows or hides the thumbnails navigator" onclick="ToggleFilmStrip()">
													<img id="stripcontrol" src="images/left.gif" border="0">
												</td>
											</tr>
											<tr>
												<td height="100%" id="filmstripframe"></td>
											</tr>
										</table>
									</asp:PlaceHolder>
								</td>
							</tr>
						</table>
					</td>
				</tr>
			</table>
		</form>
	</body>
</HTML>
